﻿namespace AgileBoard.Infrastructure.Data.Repositories
{
    using System.Collections.Generic;
    using Domain;
    using Domain.DataInterfaces;
    using SharpArch.Data.NHibernate;

    public class TaskRepository : Repository<Task>, ITaskRepository
    {
        #region ITaskRepository Members

        public IList<Task> FindByStory(string storyId)
        {
            return Session.CreateQuery("from Task where StoryID = :storyId")
                .SetParameter("storyId", storyId)
                .List<Task>();
        }

        public IList<Task> FindByStories(string stories)
        {
            return Session.CreateQuery("from Task where StoryID in P:stories")
                .SetParameter("stories", stories)
                .List<Task>();
        }

        public IList<Task> FindByStatus(string statusId)
        {
            return Session.CreateQuery("from Task where StatusID = :statusId")
                .SetParameter("statusId", statusId)
                .List<Task>();
        }

        public IList<Task> FindByIteration(string iterationId)
        {
            return Session.CreateQuery("from Task where IterationID = :iterationId")
                .SetParameter("iterationId", iterationId)
                .List<Task>();
        }

        public IList<Task> FindNonCatagorizedTasks()
        {
            return Session.CreateQuery("from Task where StoryID IS NULL").List<Task>();
        }

        #endregion
    }
}